# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libidn
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.43
pkgrel=1
pkgdesc="Implementation of the Stringprep, Punycode and IDNA specifications (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://www.gnu.org/software/libidn"
msys2_repository_url="https://gitlab.com/libidn/libidn"
msys2_references=(
  "cpe: cpe:/a:gnu:libidn"
)
license=('spdx:GPL-3.0-or-later' 'spdx:LGPL-3.0-or-later')
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-gettext-tools"
  "${MINGW_PACKAGE_PREFIX}-gtk-doc"
  "texinfo"
)
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime")
source=("https://ftp.gnu.org/gnu/libidn/${_realname}-${pkgver}.tar.gz"{,.sig})
sha256sums=('bdc662c12d041b2539d0e638f3a6e741130cdb33a644ef3496963a443482d164'
            'SKIP')
validpgpkeys=('B1D2BD1375BECB784CF4F8C4D73CF638C53C06BE') # Simon Josefsson <simon@josefsson.org>

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX}\
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --disable-csharp \
    --disable-java \
    --disable-rpath \
    --enable-threads=win32

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make check || warning "Tests failed"
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' | xargs -rtl1 rm
}
